package acm;

public class 书号验证 {
    public static void main(String[] args){
        System.out.println(f("978-7-301-04815-3"));
        System.out.println(f("978-7-115-38821-6"));
    }
    public static boolean f(String s) {
        int k = 1;
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '-' || c == ' ') continue;
            sum += (c-'0')*(k%2==0?3:1);
            k++;
            if (k > 12) break;
        }
        return s.charAt(s.length()-1)-'0' == (10-sum % 10)%10;
    }
}
